#pragma once
#include <Arduino.h>
#include <SSD1306Wire.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_SDA 21
#define OLED_SCL 22
#define TOTAL_PAGES 4  // 增加页面数量

class EnvMonitorDisplay {
public:
    EnvMonitorDisplay(uint8_t address = 0x3C, int sda = OLED_SDA, int scl = OLED_SCL);
    bool begin();
    void update(float temp, int humid, float ppm,
              bool wifiStatus, bool mqttStatus,
              int msgID, bool humanDetected, bool lightState,bool flameDetected);
    void showSplashScreen(const String& title, const String& message);
    
private:
    SSD1306Wire display;
    unsigned long lastPageChange = 0;
    uint8_t currentPage = 0;
    const uint32_t PAGE_INTERVAL = 5000;


    // 私有方法声明
    void drawHeader(const String& title);
    void showSensorPage(float temp, int humid, float ppm);
    void showNetworkPage(bool wifiStatus, bool mqttStatus, int msgID);
    void showHumanPage(bool detected);
    void drawHumanIcon(int x, int y, bool detected);
    void drawHumanIndicator(int x, int y, bool detected);
    void drawStatusIndicator(int x, int y, bool status);
    void drawWiFiSignal(int rssi);
    void drawProgressBar(int x, int y, int width, int height, float progress);

    void showFlamePage(bool flameDetected); // 新增火焰页面
    void drawFlameIcon(int x, int y, bool flameOn); // 新增火焰图标绘制
};
